/**
 * Created by zhanshen886 on 2019/1/18.
 */
$(function() {
	function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = decodeURI(window.location.search).substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}
	
	//var userId=getQueryString('userId')
	//var userId = localStorage.getItem("UserID");
	$.post('http://112.29.169.12:8090/portal-wap/noLogin/internetTv_getOrderList.msp', 
		{
//			userId:userId,
		},
		function(data) {
			console.log(data.retdata);
			var list = '';
			for(var i = 0; i < data.retdata.length; i++) {	
				if(data.retdata[i].STATE==1){
					list +="<div class='clearfix active dingdan' id='goodDetail"+i+"'><div class='name1 fl'>"+data.retdata[i].ELEC_COUPON_NAME+"</div><div class='name2 fl'>支付成功</div><div class='name3 fl'>"+data.retdata[i].MONEY/100+"元</div><div class='name4 fl'>"+data.retdata[i].CREATE_TIME+"</div></div>"
				}else if(data.retdata[i].STATE==4){
					var state='未支付 '
					list +="<div class='clearfix active dingdan' id='goodDetail"+i+"'><div class='name1 fl'>"+data.retdata[i].ELEC_COUPON_NAME+"</div><div class='name2 fl'>未支付</div><div class='name3 fl'>"+data.retdata[i].MONEY/100+"元</div><div class='name4 fl'>"+data.retdata[i].CREATE_TIME+"</div></div>"
				}else if(data.retdata[i].STATE==3){
					var state='已取消 '
					list +="<div class='clearfix active dingdan' id='goodDetail"+i+"'><div class='name1 fl'>"+data.retdata[i].ELEC_COUPON_NAME+"</div><div class='name2 fl'>已取消</div><div class='name3 fl'>"+data.retdata[i].MONEY/100+"元</div><div class='name4 fl'>"+data.retdata[i].CREATE_TIME+"</div></div>"
				}




			};
			$('#goodDetail').html(list);
			$('.dingdan').click(function(){
				var index=$(this).index();
				var ID=data.retdata[index].ID;
				var orderId=data.retdata[index].ORDER_ID;
				if(data.retdata[index].NATURE==1){//跳到实物页面
					location.href='yizhifuShiwu.html?ID='+ID+'&orderId='+orderId;
				}else{//跳转虚拟页面
					location.href='yizhifuXuni.html?ID='+ID+'&orderId='+orderId;
				}
			})
			
			
			
			
			
			
})			
})